package com.dx.cms.dao;

import com.dx.cms.domain.User;
import com.dx.util.JdbcUtil;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class UserDao {

    public List<User> checkLogin(String username, String password) throws SQLException {
        JdbcUtil util=new JdbcUtil();
        String sql="select * from tb_user where username=? and password=?";
        ResultSet rs=util.executeQuery(sql,username,password);
        List<User> list=new ArrayList<>();
        User user=null;
        while(rs.next()){
            user=new User();
            user.setId(rs.getInt("id"));
            user.setUsername(rs.getString("username"));
            user.setPassword(rs.getString("password"));
            list.add(user);
        }
        util.release();
        return list;
    }
}
